#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
using namespace std;

const int MOD = 100000000;
using vec = vector<int>;
using vec2 = vector<vector<int>>;
using vec3 = vector<vector<vector<int>>>;

int method_d(vec &grid, int m, int i, int ps, vec2 &dp)
{
	//cout << "*****************" << endl;
	if (i == grid.size()) {
		return dp[i][ps] = 1;
	}

	int maxs = 1 << m;
	int ans = 0;

	if (dp[i][ps] != -1) {
		return dp[i][ps];
	}

	for (int s = 0; s < maxs; s++) {
		if ((s & (s >> 1)) || (s & grid[i]) || (s & ps)) {
			continue;
		}
		bitset<4> bs(s);
		//cout << i << " " << bs << endl;
		ans = (ans + method_d(grid, m, i + 1, s, dp)) % MOD;
	}
	return dp[i][ps] = ans;
}

int method(vec &grid, int m, int i, int s, vec2 &dp)
{
	//cout << "*****************" << endl;
	if (i == 0) {
		return 1;
	}

	int maxs = 1 << m;
	int ans = 0;

	if (dp[i][s] != -1) {
		return dp[i][s];
	}

	for (int ps = 0; ps < maxs; ps++) {
		if ((ps & (ps >> 1)) || (ps & grid[i - 1]) || (s & ps)) {
			continue;
		}
		//bitset<4> bs(ps);
		//cout << i << " " << bs << endl;
		ans = (ans + method(grid, m, i - 1, ps, dp)) % MOD;
	}
	return dp[i][s] = ans;
}

int method(vec &grid, int n, int m)
{
	vec2 dp(n + 2, vec(1 << m, 0));
	//fill(dp[0].begin(), dp[0].end(), 1);
	dp[0][0] = 1;
	int maxs = 1 << m;

	for (int i = 1; i <= n + 1; i++) {
		for (int s = 0; s < maxs; s++) {
			if ((s & (s >> 1)) || (s & grid[i])) {
				continue;
			}
			for (int ps = 0; ps < maxs; ps++) {
				if ((ps & (ps >> 1)) || (ps & grid[i - 1]) || (s & ps)) {
					continue;
				}
				dp[i][s] = (dp[i][s] + dp[i - 1][ps]) % MOD;
			}
		}
	}
	return dp[n + 1][0];
}

int get(int s, int j)
{
	return (s >> j) & 1;
}

int set(int s, int j, int v)
{
	return v == 1 ? (s | (1 << j)) : (s & (~(1 << j)));
}

int method_line(vec &grid, int n, int m)
{
	vec2 dp(n + 4, vec(1 << m, 0));
	//fill(dp[0].begin(), dp[0].end(), 1);
	dp[0][0] = 1;
	int maxs = 1 << m;
	int ps = 0;
	for (int i = 1; i <= n + 2; i++) {
		for (int j = 0; j < m; j++) {
			for (ps = 0; ps < maxs; ps++) {
				if ((ps & (ps >> 1)) || (ps & grid[i - 1])) {
					continue;
				}

				if ((j == 0 || get(ps, j - 1) == 0) && get(ps, j) == 0 && get(~grid[i], j) == 1) {
					dp[i][set(ps, j, 1)] += dp[i - 1][ps];
				} else {
					dp[i][set(ps, j, 0)] += dp[i - 1][ps];
				}
			}
		}
	}
	return dp[n + 1][0];
}

int main()
{
	int n, m, status;
	cin >> n >> m;
	vec gird(n + 1, 0);
	for (int i = 1; i <= n; i++) {
		status = 0;
		for (int j = 0, v = 0; j < m; j++) {
			cin >> v;
			status |= (v == 0 ? (1 << j) : 0);
		}
		gird[i] = status;
	}
	vec2 dp(n + 1, vec(1 << m, -1));
	cout << method_line(gird, n, m) << endl;
	return 0;
}